
/**
 * 获取.repo目录所在目录
 * @param logger 日志记录器
 * @returns .repo目录所在目录
 */
export function getRepoPath(dirPath: string): string | undefined {
     // .repo目录所在目录
     let repoRootPath = dirPath;
     let foundRepoDir = false;
     // 从bundle.json所在目录开始，向上遍历，直到找到.repo目录
     while (repoRootPath && repoRootPath !== '/') {
         const potentialRepoDir = `${repoRootPath}/.repo`;
         const fs = require('fs');
         
         if (fs.existsSync(potentialRepoDir) && fs.statSync(potentialRepoDir).isDirectory()) {
             foundRepoDir = true;
             break;
         }
         // Move up one directory
         repoRootPath = repoRootPath.substring(0, repoRootPath.lastIndexOf('/'));
     }
     
     if (!foundRepoDir) {
        return undefined;
     }

     return repoRootPath;
}